@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />
@endsection

@section('html-body')
        <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">订单列表</a>
        </div>
        <!-- cur-position end -->

        <!--filter-box start-->
        <div class="filter-box clearfix">
            <div class="fl">
                <span class="search-bd">
                {{--<form id="form_promoter">--}}
                    <input type="text" class="search-ipt" name="pro_name" placeholder="粉丝昵称" value="" id="nickname">
                    <input class="search-smt" type="button">
                    {{--</form>--}}
            </span>
            </div>
        </div>
        <!--filter-box end-->

        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>就诊ID</th>
                    <th>昵称</th>
                    <th>真实姓名</th>
                    <th>手机号</th>
                    <th>出生日期</th>
                    <th>订单编号</th>
                    <th>订单类别</th>
                    <th>缴费项</th>
                    <th>付款时间</th>
                    <th>预约日期</th>
                    <th>时间段</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="fansinfo">
                    @if($orders && count($orders) > 0)
                        @foreach($orders as $order)
                        <tr>
                            <td>{{$order->uid}}</td>
                            <td class="account-td">
                        <span class="photo">
                            <img src="{{route('Api.Image.Show',['id'=>$order->user_img])}}" alt="">
                        </span>
                                <div class="info-box">
                                    <p>
                                        <span class="name">{{$order->nickname}}</span>
                                        @if((int)$order->sexual == 0)
                                        <img class="sex" src="{{url('/images/girl.gif')}}" alt="" style="">
                                            @elseif((int)$order->sexual == 1)
                                            <img class="sex" src="{{url('/images/boy.gif')}}" alt="" style="">
                                        @endif
                                    </p>
                                    <p class="star-level-box">
                                        <span class="num-level"></span>
                                    </p>
                                </div>
                            </td>
                            <td>{{$order->patient_name}}</td>
                            <td>{{$order->patient_phone}}</td>
                            <td>{{$order->patient_birth}}</td>
                            <td>{{$order->order_num}}</td>
                            <td>@if($order->type == 'package')<span style="color: #996600">缴费项</span> @elseif((int)$order->type == 0)<span style="color:#FF3399;">挂号</span>  @endif</td>
                            <td>{{$order->title}}</td>
                            <td>{{$order->pay_time}}</td>
                            <td><span style="color: #CC0033"> {{date('Y-m-d',strtotime($order->bespoke_time))}}</span></td>
                            <td>@if($order->bespoke_slot == 'am')上午@elseif($order->bespoke_slot == 'pm')下午@else无 @endif</td>
                            <td>@if((int)$order->status == 0)<span class="color2">未使用</span>@elseif((int)$order->status == 1)<span class="color5">已完成</span>@elseif((int)$order->status == 2)<span class="color3">已结束</span> @endif</td>
                            <td class="btna"><a class="btnLump btnLump1" href="" data-id="{{$order->id}}">完成</a></td>
                        </tr>
                        @endforeach
                        @endif
                </tbody>
            </table>
        </div>
        <div>
            {!! $orders->render() !!}
        </div>
    </div>
    <!-- content end -->
    <script type="text/javascript">

        $(function() {
            jQuery.ajaxSetup({
                case: false,
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $('.btna a').click(function(){
                var id = $(this).attr('data-id');
                $.ajax({
                    type:"post",
                    url:'{{route('Api.Order.confimOrder')}}',
                    dataType:"json",
                    data:{'id':id},
                    success:function(obj){
                        if(obj.level == "success"){
                            noty({text:obj.message,type:obj.level,timeout:800,
                                callback:{
                                    afterClose:function(){
                                        location.reload();
                                    }
                                }
                            });
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        noty({text: datajson.message, type: 'error', timeout: 600});
                    }
                });
            });


            //按回车登录
            $(document).keyup(function(event){
                if(event.keyCode ==13){
                    $(".search-smt").trigger("click");
                }
            });

            $(".search-smt").click(function(){
                var nickname = $('#nickname').val();
                var photourl = '';
                var wechatfimg = '';
                var wechatpimg = '';
                var fansdefault = '';
                var xingxing = '';
                $.ajax({
                    type:"post",
                    url:'',
                    dataType:"json",
                    data:{'keyword':nickname},
                    success:function(obj){
                        if(obj.level == "success"){
                            $('#fansinfo').html('');
                            var fans = obj.data;
                            for(var i=0;i< fans.length;i++){
                                var allcountmoney = parseFloat(fans[i].open_money) + parseFloat(fans[i].frozen_money);
                                var content1 = '<tr>'+
                                        '<td><input class="chkbox" type="checkbox" value="1505" name="cart"></td>'+
                                        '<td class="account-td">'+
                                        '<span class="photo"><img src="'+photourl+'/'+fans[i].user_id+'" alt=""></span>'+
                                        '<div class="info-box"><p>'+
                                        '<span class="icon icon-rzh"></span>'+
                                        '<span class="name">'+fans[i].nickname+'</span>'+
                                        '<img class="sex" src="'+xingxing+'" alt="" style="">'+
                                        '</p>'+
                                        '<p class="star-level-box">'+
                                        '<span class="star-level">'+
                                        '<cite style="width: 72px;"></cite>'+
                                        '</span>'+
                                        '<span class="num-level">'+fans[i].score+'</span>'+
                                        '</p>'+
                                        '</div>'+
                                        '</td>'+
                                        '<td>'+fans[i].partnerName+'</td>'+
                                        '<td>'+fans[i].province+fans[i].city+fans[i].area+'</td>'+
                                        '<td>'+fans[i].fanscount+'</td>'+
                                        '<td><span class="color2">￥'+fans[i].open_money+'</span></td>'+
                                        '<td><span class="color2">￥'+allcountmoney+'</span></td>'+
                                        '<td><a class="btnLump btnLump1" href="javascript:void(0);" onclick="upPop("'+fans[i].worth+'","'+fans[i].taskNum+'","'+fans[i].wechat_fans+'","'+fans[i].taskIsPassNum+'","'+wechatfimg+'/'+fans[i].user_id+'","'+wechatpimg+'/'+fans[i].user_id+'")">查看</a></td>';

                                switch (fans[i].status){
                                    case 0:
                                        content1 += '<td><span class="color2">未审核</span></td>';
                                        break;
                                    case 1:
                                        content1 += '<td><span class="color4">通过审核</span></td>';
                                        break;
                                    case 2:
                                        content1 += '<td><span class="color3">审核不通过</span></td>';
                                        break;
                                    default :
                                        content1 += '<td>锁定</td>';
                                }

                                content1 += '<td class="grade"><input type="text" style="width: 12%" data-id="'+fans[i].user_id+'" value="'+fans[i].grade+'" /></td>'+
                                        '<td><a class="btnLump btnLump1" href="'+fansdefault+'/'+fans[i].id+'">查看</a></td></tr>';

                                $('#fansinfo').append(content1);
                            }
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        noty({text: datajson.message, type: 'error', timeout: 600});
                    }
                });
            });
        });
    </script>
@endsection